﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ReportViewer
{
    internal partial class FrmSettings : Form
    {
        internal FrmSettings()
        {
            InitializeComponent();

            this.SetUIFromApplicationSettings();
        }

        private void SetUIFromApplicationSettings()
        {
            this.txtBxServerName.Text = Properties.Settings.Default.ServerName;
            this.nupServerPort.Value = Properties.Settings.Default.ServerPort;
            this.chkBxAutomaticallyConnect.Checked = Properties.Settings.Default.ConnectAtStartup;
        }

        #region {Response to UI events}

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnOk_Click(object sender, EventArgs e)
        {
            Properties.Settings.Default.ServerName = this.txtBxServerName.Text;
            Properties.Settings.Default.ServerPort = (int)this.nupServerPort.Value;
            Properties.Settings.Default.ConnectAtStartup = this.chkBxAutomaticallyConnect.Checked;

            Properties.Settings.Default.Save();
            this.Close();
        }

        #endregion {Response to UI events}
    }
}
